import { Tools } from 'weaver-mobile';
import { catchApiError } from '../util/index';

// 新建日程基础数据
export const getCreateWorkplanBaseData = params => {
  let options = {
    method: 'POST',
    url: '/api/workplan/base/getBaseData',
    params: {...params, ismobile: 1}
  };
  return Tools.callApi(options).then(catchApiError);
}

// 查看日程数据
export const viewWorkplanBaseData = params => {
  let options = {
    method: 'POST',
    url: '/api/workplan/base/view',
    params: {...params, ismobile: 1}
  };
  return Tools.callApi(options).then(catchApiError);
}

// 新建日程
export const createWorkplan = params => {
  let options = {
    method: 'POST',
    url: '/api/workplan/base/add',
    params: {...params, ismobile: 1}
  };
  return Tools.callApi(options).then(catchApiError);
}

// 日程接收人校验
export const workplanMemberChk = params => {
  let options = {
    method: 'POST',
    url: '/api/workplan/base/workplanMemberChk',
    params: {...params, ismobile: 1}
  };
  return Tools.callApi(options).then(catchApiError);
}

// 删除日程
export const deleteWorkplan = params => {
  let options = {
    method: 'POST',
    url: '/api/workplan/base/delete',
    params: {...params, ismobile: 1}
  };
  return Tools.callApi(options).then(catchApiError);
}

// 完成日程
export const finishWorkplan = params => {
  let options = {
    method: 'POST',
    url: '/api/workplan/base/finish',
    params: {...params, ismobile: 1}
  };
  return Tools.callApi(options).then(catchApiError);
}

export const getExchangeHrmList = params => {
  return Tools.callApi({
    url: '/api/workplan/exchange/getExchangeHrmList',
    method: 'POST',
    params,
});
}

export const deleteExchange = params => {
  return Tools.callApi({
    url: '/api/workplan/exchange/delete',
    method: 'POST',
    params,
});
}

// 日程交流提交
export const submitReply = params => {
  return Tools.callApi({
      url: '/api/workplan/exchange/save',
      method: 'POST',
      params,
  });
};

// 会议交流提交
export const pushMessage = params => {
  return Tools.callApi({
      url: '/api/ec/dev/message/groupsendmessage',
      method: 'POST',
      params,
  });
};

// 删除周期日程
export const deleteModulWorkplan = params => {
  let options = {
    method: 'POST',
    url: '/api/workplan/modul/del',
    params: {...params, ismobile: 1}
  };
  return Tools.callApi(options).then(catchApiError);
}

// 语音新建日程
export const addByWord = params => {
  let options = {
    method: 'POST',
    url: '/api/workplan/base/addByWord',
    params: {...params, ismobile: 1}
  };
  return Tools.callApi(options).then(catchApiError);
}